#!/bin/sh

QMKSPEC=$1
XPLATFORM=`basename $1`
VERBOSE=$2
SRCDIR=$3
OUTDIR=$4

# debuggery
[ "$VERBOSE" = "yes" ] && echo "Detecting broken Gix headers... ($*)"

# Detect broken GIX headers when using GCC 2.95 or later
#   Xsun on Solaris 2.5.1:
#   	Patches are available for Solaris 2.6, 7, and 8 but
#   	not for Solaris 2.5.1.
#   HP-UX:
#   	Patches are available for HP-UX 10.20, 11.00, and 11.11.
#   AIX 4.3.3 and AIX 5.1:
#   	Headers are clearly broken on all AIX versions, and we
#   	don't know of any patches. The strange thing is that we
#   	did not get any reports about this issue until very
#   	recently, long after gcc 3.0.x was released. It seems to
#   	work for us with gcc 2.95.2.
NOTYPE=no

if [ $XPLATFORM = "solaris-g++" -o $XPLATFORM = "hpux-g++" -o $XPLATFORM = "aix-g++" -o $XPLATFORM = "aix-g++-64" ]; then
    NOTYPE=yes

    test -d "$OUTDIR/config.tests/gix/notype" || mkdir -p "$OUTDIR/config.tests/gix/notype"
    "$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" "$SRCDIR/config.tests/gix/notype/notypetest.pro" -o "$OUTDIR/config.tests/gix/notype/Makefile" >/dev/null 2>&1
    cd "$OUTDIR/config.tests/gix/notype"

    if [ "$VERBOSE" = "yes" ]; then
	$MAKE
    else
	$MAKE >/dev/null 2>&1
    fi

    [ -x notypetest ] && NOTYPE=no
fi

# done
if [ "$NOTYPE" = "yes" ]; then
    [ "$VERBOSE" = "yes" ] && echo "Broken GIX headers detected."
    exit 0
else
    [ "$VERBOSE" = "yes" ] && echo "GIX headers look good."
    exit 1
fi
